<?php	namespace Home\Controller;
class LogoController extends CommonController
{
	public function index()
	{
		if(IS_POST){
			$username = $_POST['username'];
			$password = md5($_POST['mima']);
			
			if(strtolower($_POST['yanzen']) != strtolower($_SESSION['code'])) {
				return View::error('验证码错误');
			}
			$dataUser = Db::table('user')->where('yname',$username)->get();
			if(!$dataUser){
				return View::error('账号错误');
			}
			$dataUser = Db::table('user')->where('yhpassword',$password)->get();
			if(!$dataUser){
				return View::error('密码错误');
			}
			$dataUser = Db::table('user')->where('yname',$username)->where('yhpassword',$password)->first();
			if($dataUser){
				$_SESSION['yid'] = $dataUser['yid'];
				$_SESSION['nickname'] = $dataUser['nickname'];
				View::success('登录成功','Index/index');
			}
		}
		View::make();
	}
	public function code()
	{
		Code::make();
	}
	public function del()
	{
		session_unset();
		session_destroy();
		View::success('退出成功','index');
	}
}
